<?php
namespace Application\Api\Controller;

class Feedback extends Base
{

    private function getService()
    {
        return $this->get(SERVICE_FEEDBACK);
    }

    /*
        /Api/Feedback/getUploadData
    */
    public function getUploadDataAction()
    {
        $data = $this->get(SERVICE_OSS)->getUploadData('feedback');
        $this->sendSuccess($data);
    }

    /*
        /Api/Feedback/add
    */
    public function addAction()
    {
        $data = $this->getRequestData();
        if(notSetOrEmpty($data, 'device')){
            $this->sendFail('PARAMETER_ERROR', '', __LINE__);
            return false;
        }
        $device = $data['device'];
        $serviceUser = $this->get(SERVICE_USER);
        $userId = $serviceUser->checkToken($data, $device);
        if(!$userId){
            $userId = 0;
        }
        $this->getService()->addData($userId, $data['type'], $data['fileIds'], $data['content']);
        $this->sendSuccess();
    }

}